<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
	<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
	<title>微信支付页</title>
	<link rel="icon" href="./img/favicon.ico">


	<link rel="stylesheet" type="text/css" href="./css/all.css" />
	<link rel="stylesheet" type="text/css" href="./css/pages-weixinpay.css" />
	<!-- <link rel="stylesheet" href="./../static/css/all.css">
	<link rel="stylesheet" href="./../static/css/pages-weixinpay.css"> -->
</head>

<body>
	<div id="app">
		<!--head-->
		<div class="top">
			<div class="py-container">
				<div class="shortcut">
					<ul class="fl">
						<li class="f-item">NXMALL欢迎您！</li>
						<li class="f-item">
							{{ username }}
							<!-- 请登录　<span><a href="#">免费注册</a></span> -->
						</li>
					</ul>
					<ul class="fr">
						<li class="f-item"><span><a href="http://mall.web.netlearning.tech:9103/user/findOrder"
							target="_blank">我的订单</a></span></li>
						<li class="f-item space"></li>
						<li class="f-item">我的NXMALL</li>
						<li class="f-item space"></li>
						<li class="f-item">NXMALL会员</li>
						<li class="f-item space"></li>
						<li class="f-item">企业采购</li>
						<li class="f-item space"></li>
						<li class="f-item">关注NXMALL</li>
						<li class="f-item space"></li>
						<li class="f-item">客户服务</li>
						<li class="f-item space"></li>
						<li class="f-item">网站导航</li>
					</ul>
				</div>
			</div>
		</div>
		<div class="cart py-container">
			<!--logoArea-->
			<div class="logoArea">
				<div class="fl logo">
					<!-- <span class="title">收银台</span> -->
				</div>
			</div>
			<!--主内容-->
			<div class="checkout py-container  pay">
				<div class="checkout-tit" id="app">
					<h4 class="fl tit-txt"><span class="success-icon"></span><span
							class="success-info">订单提交成功，请您及时付款！订单号：{{orderId}}</span></h4>
					<span class="fr"><em class="sui-lead">应付金额：</em><em class="orange money">￥{{ (money/100).toFixed(2)
							}}</em>元</span>
					<div class="clearfix"></div>
				</div>
				<div class="checkout-steps">
					<div class="fl weixin">微信支付</div>
					<div class="fl sao">
						<!-- <p class="red">二维码已过期，刷新页面重新获取二维码。</p> -->
						<div class="fl code">
							<div id="pay-qrcode"></div>
							<div class="saosao" style="text-align: center;padding: 8px;">
								<p>请使用微信扫一扫</p>
								<p>扫描二维码支付</p>
							</div>
						</div>
						<div class="fl phone">

						</div>

					</div>
					<div class="clearfix"></div>
					<!-- <p><a href="pay.html" target="_blank">> 其他支付方式</a></p> -->
				</div>
			</div>

		</div>
		<!-- 底部栏位 -->
		<!--页面底部-->
		<div class="clearfix footer">
			<div class="py-container">
				<div class="footlink">
					<div class="Mod-service">
						<ul class="Mod-Service-list">
							<li class="grid-service-item intro  intro1">

								<i class="serivce-item fl"></i>
								<div class="service-text">
									<h4>正品保障</h4>
									<p>正品保障，提供发票</p>
								</div>

							</li>
							<li class="grid-service-item  intro intro2">

								<i class="serivce-item fl"></i>
								<div class="service-text">
									<h4>正品保障</h4>
									<p>正品保障，提供发票</p>
								</div>

							</li>
							<li class="grid-service-item intro  intro3">

								<i class="serivce-item fl"></i>
								<div class="service-text">
									<h4>正品保障</h4>
									<p>正品保障，提供发票</p>
								</div>

							</li>
							<li class="grid-service-item  intro intro4">

								<i class="serivce-item fl"></i>
								<div class="service-text">
									<h4>正品保障</h4>
									<p>正品保障，提供发票</p>
								</div>

							</li>
							<li class="grid-service-item intro intro5">

								<i class="serivce-item fl"></i>
								<div class="service-text">
									<h4>正品保障</h4>
									<p>正品保障，提供发票</p>
								</div>

							</li>
						</ul>
					</div>
					<div class="clearfix Mod-list">
						<div class="yui3-g">
							<div class="yui3-u-1-6">
								<h4>购物指南</h4>
								<ul class="unstyled">
									<li>购物流程</li>
									<li>会员介绍</li>
									<li>生活旅行/团购</li>
									<li>常见问题</li>
									<li>购物指南</li>
								</ul>

							</div>
							<div class="yui3-u-1-6">
								<h4>配送方式</h4>
								<ul class="unstyled">
									<li>上门自提</li>
									<li>211限时达</li>
									<li>配送服务查询</li>
									<li>配送费收取标准</li>
									<li>海外配送</li>
								</ul>
							</div>
							<div class="yui3-u-1-6">
								<h4>支付方式</h4>
								<ul class="unstyled">
									<li>货到付款</li>
									<li>在线支付</li>
									<li>分期付款</li>
									<li>邮局汇款</li>
									<li>公司转账</li>
								</ul>
							</div>
							<div class="yui3-u-1-6">
								<h4>售后服务</h4>
								<ul class="unstyled">
									<li>售后政策</li>
									<li>价格保护</li>
									<li>退款说明</li>
									<li>返修/退换货</li>
									<li>取消订单</li>
								</ul>
							</div>
							<div class="yui3-u-1-6">
								<h4>特色服务</h4>
								<ul class="unstyled">
									<li>夺宝岛</li>
									<li>DIY装机</li>
									<li>延保服务</li>
									<li>NXMALLE卡</li>
									<li>NXMALL通信</li>
								</ul>
							</div>
							<div class="yui3-u-1-6">
								<h4>帮助中心</h4>
								<img src="./img/wx_cz.jpg">
							</div>
						</div>
					</div>
					<div class="Mod-copyright">
						<ul class="helpLink">
							<li>关于我们<span class="space"></span></li>
							<li>联系我们<span class="space"></span></li>
							<li>关于我们<span class="space"></span></li>
							<li>商家入驻<span class="space"></span></li>
							<li>营销中心<span class="space"></span></li>
							<li>友情链接<span class="space"></span></li>
							<li>关于我们<span class="space"></span></li>
							<li>营销中心<span class="space"></span></li>
							<li>友情链接<span class="space"></span></li>
							<li>关于我们</li>
						</ul>
						<p>地址：北京市海淀区建材城东路金隅智造工场 邮编：100096 </p>
						<p>京ICP备21001421号京公网安备110102108808</p>
					</div>
				</div>
			</div>
		</div>
		<!--页面底部END-->
	</div>

	<script src="/js/vue.js"></script>
	<script src="/js/axios.js"></script>
	<script src="/js/qrcode.min.js"></script>
	<script src="/js/util.js"></script>
	<!-- <script src="./../static/js/vue.js"></script>
	<script src="./../static/js/axios.js"></script>
	<script src="./../static/js/qrcode.min.js"></script>
	<script src="./../static/js/util.js"></script> -->
	<script>
		// var qrcode = new QRCode(document.getElementById("pay-qrcode"), {
		// 	width: 200,
		// 	height: 200
		// });

		new Vue({
			el: '#app',
			data() {
				return {
					orderId: "",
					money: "",
					timer: null,
					username: '',
					qrcode: null
				}
			},
			mounted() {
				console.log('mounted');
				this.createNative();
				this.username = sessionStorage.getItem('usrname')
			},
			destroyed: function () {
				// 每次离开当前界面时，清除定时器
				clearInterval(this.timer)
			},
			methods: {
				createNative() {
					let orderId = getQueryString("orderId"); //获取订单Id
					console.log(orderId)
					axios.get(`/pay/createNative?orderId=${orderId}`).then(response => {
						if (response.data.out_trade_no != null) {
							this.qrcode = new QRCode(document.getElementById("pay-qrcode"), {
								width: 200,
								height: 200
							});
							this.qrcode.makeCode(response.data.code_url);// 生成二维码
							this.orderId = response.data.out_trade_no;
							this.money = response.data.total_fee;
							this.setTimer()
						} else {
							location.href = 'payfail.html';//跳转支付失败页面
						}
					});
				},
				queryPayStatus() {
					axios.get(`/pay/queryPayStatus?orderId=${this.orderId}`).then(response => {
						if (response.data.result_code == 'SUCCESS') {//有成功的返回结果
							if (response.data.trade_state == 'SUCCESS') {//交易状态为成功
								location.href = 'paysuccess.html';//跳转支付成功页面
							}
						} else {
							location.href = 'payfail.html';//跳转支付失败页面
						}
					});
				},
				setTimer() {
					if (this.timer == null) {
						this.timer = setInterval(() => {
							console.log('开始定时...每过3秒执行一次')
							this.queryPayStatus()//查询支付状态
						}, 3000)
					}
				}
			}
		})
	</script>



</body>

</html>
